<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Main</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Main' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="index.html">inblorb</a></li><li><a href="index.html#1">Chapter 1: Blurbs</a></li><li><b>Main</b></li></ul></div>
<p class="purpose">To parse command-line arguments, then start the Blurb interpreter, then report back to the user.</p>

<ul class="toc"><li><a href="1-mn.html#SP1">&#167;1. Some globals</a></li><li><a href="1-mn.html#SP3">&#167;3. Main</a></li><li><a href="1-mn.html#SP6">&#167;6. Opening and closing banners</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Some globals.</b>The following variables record HTML and Javascript-related points where
Inblorb needs to behave differently on the different platforms. The default
values here aren't actually correct for any platform as they stand: in the
<span class="extract"><span class="extract-syntax">main</span></span> routine below, we set them as needed.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> *</span><span class="identifier-syntax">FONT_TAG</span><span class="plain-syntax"> = </span><span class="identifier-syntax">U</span><span class="string-syntax">"size=2"</span><span class="plain-syntax">; </span><span class="comment-syntax"> contents of a </span><span class="extract"><span class="extract-syntax">&lt;font&gt;</span></span><span class="comment-syntax"> tag</span>
<span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> *</span><span class="identifier-syntax">JAVASCRIPT_PRELUDE</span><span class="plain-syntax"> = </span><span class="identifier-syntax">U</span><span class="string-syntax">"javascript:window.Project."</span><span class="plain-syntax">; </span><span class="comment-syntax"> calling prefix</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">escape_openUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">escape_fileUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse_slash_openUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">reverse_slash_fileUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>Some global variables:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">error_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of error messages produced so far</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">verbose_mode</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">; </span><span class="comment-syntax"> print diagnostics to </span><span class="extract"><span class="extract-syntax">stdout</span></span><span class="comment-syntax"> while running?</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">current_year_AD</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> e.g., 2008</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">blorb_file_size</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> size in bytes of the blorb file written</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_pictures_included</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of picture resources included in the blorb</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_sounds_included</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of sound resources included in the blorb</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_data_files_included</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of data resources included in the blorb</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">HTML_pages_created</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of pages created in the website, if any</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">source_HTML_pages_created</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of those holding source</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">sound_resource_num</span><span class="plain-syntax"> = </span><span class="constant-syntax">3</span><span class="plain-syntax">; </span><span class="comment-syntax"> current sound resource number we're working on</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">picture_resource_num</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> current picture resource number we're working on</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">data_file_resource_num</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> current data resource number we're working on</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">use_css_code_styles</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">; </span><span class="comment-syntax"> use </span><span class="extract"><span class="extract-syntax">&lt;span class="X"&gt;</span></span><span class="comment-syntax"> markings when setting code</span>
<span class="reserved-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">project_folder</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="comment-syntax"> pathname of I7 project folder, if any</span>
<span class="reserved-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">release_folder</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="comment-syntax"> pathname of folder for website to write, if any</span>
<span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">status_template</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="comment-syntax"> filename of report HTML page template, if any</span>
<span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">status_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="comment-syntax"> filename of report HTML page to write, if any</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">cover_exists</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">; </span><span class="comment-syntax"> an image is specified as cover art</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">default_cover_used</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">; </span><span class="comment-syntax"> but it's only the default supplied by Inform</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">cover_is_in_JPEG_format</span><span class="plain-syntax"> = </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">; </span><span class="comment-syntax"> as opposed to </span><span class="extract"><span class="extract-syntax">PNG</span></span><span class="comment-syntax"> format</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Main.</b>Like most programs, this one parses command-line arguments, sets things up,
reads the input and then writes the output.
</p>

<p class="commentary">That's a little over-simplified, though, because it also produces auxiliary
outputs along the way, in the course of parsing the blurb file. The blorb
file is only the main output &mdash; there might also be a web page and a solution
file, for instance.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">blorb_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">main</span><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">argc</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">argv</span><span class="plain-syntax">[]) {</span>
<span class="plain-syntax">    </span><a href="../foundation/1-fm.html#SP8" class="function-link"><span class="function-syntax">Foundation::start</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">argc</span><span class="plain-syntax">, </span><span class="identifier-syntax">argv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="1-bsc.html#SP4" class="function-link"><span class="function-syntax">Basics::register_mreasons</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax"> = </span><a href="../foundation/3-fln.html#SP2" class="function-link"><span class="function-syntax">Filenames::in</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Release.blurb"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">blorb_filename</span><span class="plain-syntax"> = </span><a href="../foundation/3-fln.html#SP2" class="function-link"><span class="function-syntax">Filenames::in</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"story.zblorb"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="1-mn.html#SP3_1" class="named-paragraph-link"><span class="named-paragraph">Make the default settings</span><span class="named-paragraph-number">3.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="1-mn.html#SP3_2" class="named-paragraph-link"><span class="named-paragraph">Parse command-line arguments</span><span class="named-paragraph-number">3.2</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><a href="3-plc.html#SP2" class="function-link"><span class="function-syntax">Placeholders::initialise</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="1-mn.html#SP6" class="function-link"><span class="function-syntax">Main::print_banner</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><a href="1-bp.html#SP1" class="function-link"><span class="function-syntax">Parser::parse_blurb_file</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-bw.html#SP26" class="function-link"><span class="function-syntax">Writer::write_blorb_file</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">blorb_filename</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-rls.html#SP6" class="function-link"><span class="function-syntax">Requests::create_requested_material</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><a href="1-mn.html#SP7" class="function-link"><span class="function-syntax">Main::print_report</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><a href="../foundation/1-fm.html#SP9" class="function-link"><span class="function-syntax">Foundation::end</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">error_count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3_1" class="paragraph-anchor"></a><b>&#167;3.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make the default settings</span><span class="named-paragraph-number">3.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">release_folder</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">project_folder</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">status_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">status_template</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="1-mn.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2" class="paragraph-anchor"></a><b>&#167;3.2. </b>We use Foundation's standard command-line routines.
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">VERBOSE_CLSW</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">PROJECT_CLSW</span>
</pre>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Parse command-line arguments</span><span class="named-paragraph-number">3.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="1-mn.html#SP3_2_1" class="named-paragraph-link"><span class="named-paragraph">Read the command-line switches</span><span class="named-paragraph-number">3.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="1-mn.html#SP3_2_2" class="named-paragraph-link"><span class="named-paragraph">Set platform-dependent HTML and Javascript variables</span><span class="named-paragraph-number">3.2.2</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">verbose_mode</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">PRINT</span><span class="plain-syntax">(</span><span class="string-syntax">"! Blurb in: &lt;%f&gt;\n! Blorb out: &lt;%f&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax">, </span><span class="identifier-syntax">blorb_filename</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="1-mn.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2_1" class="paragraph-anchor"></a><b>&#167;3.2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Read the command-line switches</span><span class="named-paragraph-number">3.2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><a href="../foundation/3-cla.html#SP2" class="function-link"><span class="function-syntax">CommandLine::declare_heading</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">U</span><span class="string-syntax">"inblorb: a releaser and packager for IF story files\n\n"</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">U</span><span class="string-syntax">"usage: inblorb [-options] [blurbfile [blorbfile]]\n"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><a href="../foundation/3-cla.html#SP6" class="function-link"><span class="function-syntax">CommandLine::declare_boolean_switch</span></a><span class="plain-syntax">(</span><span class="constant-syntax">VERBOSE_CLSW</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"verbose"</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">U</span><span class="string-syntax">"print running notes on what's happening"</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="../foundation/3-cla.html#SP5" class="function-link"><span class="function-syntax">CommandLine::declare_switch</span></a><span class="plain-syntax">(</span><span class="constant-syntax">PROJECT_CLSW</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"project"</span><span class="plain-syntax">, </span><span class="constant-syntax">2</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">U</span><span class="string-syntax">"work within Inform project X"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">bare_words</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="../foundation/3-cla.html#SP8" class="function-link"><span class="function-syntax">CommandLine::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">argc</span><span class="plain-syntax">, </span><span class="identifier-syntax">argv</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">bare_words</span><span class="plain-syntax">, &amp;</span><a href="1-mn.html#SP4" class="function-link"><span class="function-syntax">Main::switch</span></a><span class="plain-syntax">, &amp;</span><a href="1-mn.html#SP4" class="function-link"><span class="function-syntax">Main::bareword</span></a><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">project_folder</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bare_words</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><a href="../foundation/3-em.html#SP2" class="function-link"><span class="function-syntax">Errors::fatal</span></a><span class="plain-syntax">(</span><span class="string-syntax">"if -project is used, no other filenames should be given"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax"> = </span><a href="../foundation/3-fln.html#SP2" class="function-link"><span class="function-syntax">Filenames::in</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">project_folder</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Release.blurb"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">pathname</span><span class="plain-syntax"> *</span><span class="identifier-syntax">Build</span><span class="plain-syntax"> = </span><a href="../foundation/3-pth.html#SP4" class="function-link"><span class="function-syntax">Pathnames::down</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">project_folder</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Build"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">blorb_filename</span><span class="plain-syntax"> = </span><a href="../foundation/3-fln.html#SP2" class="function-link"><span class="function-syntax">Filenames::in</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Build</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"output.zblorb"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bare_words</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="1-mn.html#SP3_2">&#167;3.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Main::switch</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Main::switch</span></span>:<br/><a href="1-mn.html#SP3_2_1">&#167;3.2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">id</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">arg</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">id</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">VERBOSE_CLSW:</span><span class="plain-syntax"> </span><span class="identifier-syntax">verbose_mode</span><span class="plain-syntax"> = </span><span class="identifier-syntax">val</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROJECT_CLSW:</span><span class="plain-syntax"> </span><span class="identifier-syntax">project_folder</span><span class="plain-syntax"> = </span><a href="../foundation/3-pth.html#SP5" class="function-link"><span class="function-syntax">Pathnames::from_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">arg</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">default:</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"unimplemented switch"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Main::bareword</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Main::bareword</span></span>:<br/><a href="1-mn.html#SP3_2_1">&#167;3.2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">id</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">opt</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bare_words</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">state</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    (*</span><span class="identifier-syntax">bare_words</span><span class="plain-syntax">)++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (*</span><span class="identifier-syntax">bare_words</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">blurb_filename</span><span class="plain-syntax"> = </span><a href="../foundation/3-fln.html#SP3" class="function-link"><span class="function-syntax">Filenames::from_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">blorb_filename</span><span class="plain-syntax"> = </span><a href="../foundation/3-fln.html#SP3" class="function-link"><span class="function-syntax">Filenames::from_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">default:</span><span class="plain-syntax"> </span><a href="../foundation/3-em.html#SP2" class="function-link"><span class="function-syntax">Errors::fatal</span></a><span class="plain-syntax">(</span><span class="string-syntax">"bad command line usage (see -help)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3_2_2" class="paragraph-anchor"></a><b>&#167;3.2.2. </b>Now let's set the platform-dependent variables.
</p>

<p class="commentary">Inblorb generates quite a variety of HTML, for instance to create websites,
but the tricky points below affect only one special page not browsed by
the general public: the results page usually called <span class="extract"><span class="extract-syntax">StatusCblorb.html</span></span>
(though this depends on how the <span class="extract"><span class="extract-syntax">status</span></span> command is used in the blurb).
The results page is intended only for viewing within the Inform user
interface, and it expects to have two Javascript functions available,
<span class="extract"><span class="extract-syntax">openUrl</span></span> and <span class="extract"><span class="extract-syntax">fileUrl</span></span>. The first opens a URL in the local operating
system's default web browser, the second opens a file (identified by a
<span class="extract"><span class="extract-syntax">file:...</span></span> URL) in the local operating system. These two URLs may need
treatment to handle special characters:
</p>

<ul class="items"><li>(a) "escaping", where spaces in the URL are escaped to <span class="extract"><span class="extract-syntax">%2520</span></span>, which
within a Javascript string literal produces <span class="extract"><span class="extract-syntax">%20</span></span>, the standard way to
represent a space in a web URL;
</li><li>(b) "reversing slashes", where backslashes are converted to forward
slashes &mdash; useful if the separation character is a backslash, as on Windows,
since backslashes are escape characters in Javascript literals.
</li></ul>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Set platform-dependent HTML and Javascript variables</span><span class="named-paragraph-number">3.2.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">PLATFORM_WINDOWS</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FONT_TAG</span><span class="plain-syntax"> = </span><span class="identifier-syntax">U</span><span class="string-syntax">"face=\"lucida grande,geneva,arial,tahoma,verdana,helvetica,helv\" size=2"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">escape_openUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">; </span><span class="comment-syntax"> we want </span><span class="extract"><span class="extract-syntax">openUrl</span></span><span class="comment-syntax"> to escape, and </span><span class="extract"><span class="extract-syntax">fileUrl</span></span><span class="comment-syntax"> not to</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">PLATFORM_WINDOWS</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">reverse_slash_openUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">; </span><span class="identifier-syntax">reverse_slash_fileUrl</span><span class="plain-syntax"> = </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="1-mn.html#SP3_2">&#167;3.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The placeholder variable [YEAR] is initialised to the year in which Inblorb
runs, according to the host operating system, at least. (It can of course then
be overridden by commands in the blurb file, and Inform always does this in
the blurb files it writes. But it leaves [DATESTAMP] and [TIMESTAMP] alone.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Main::initialise_time_variables</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Main::initialise_time_variables</span></span>:<br/>Placeholders - <a href="3-plc.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">datestamp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">infocom</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">timestamp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">weekdays</span><span class="plain-syntax">[] = { </span><span class="string-syntax">"Sunday"</span><span class="plain-syntax">, </span><span class="string-syntax">"Monday"</span><span class="plain-syntax">, </span><span class="string-syntax">"Tuesday"</span><span class="plain-syntax">, </span><span class="string-syntax">"Wednesday"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Thursday"</span><span class="plain-syntax">, </span><span class="string-syntax">"Friday"</span><span class="plain-syntax">, </span><span class="string-syntax">"Saturday"</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">months</span><span class="plain-syntax">[] = { </span><span class="string-syntax">"January"</span><span class="plain-syntax">, </span><span class="string-syntax">"February"</span><span class="plain-syntax">, </span><span class="string-syntax">"March"</span><span class="plain-syntax">, </span><span class="string-syntax">"April"</span><span class="plain-syntax">, </span><span class="string-syntax">"May"</span><span class="plain-syntax">, </span><span class="string-syntax">"June"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"July"</span><span class="plain-syntax">, </span><span class="string-syntax">"August"</span><span class="plain-syntax">, </span><span class="string-syntax">"September"</span><span class="plain-syntax">, </span><span class="string-syntax">"October"</span><span class="plain-syntax">, </span><span class="string-syntax">"November"</span><span class="plain-syntax">, </span><span class="string-syntax">"December"</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">    </span><a href="3-plc.html#SP4" class="function-link"><span class="function-syntax">Placeholders::set_to_number</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"YEAR"</span><span class="plain-syntax">, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">+1900);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">datestamp</span><span class="plain-syntax">, </span><span class="string-syntax">"%s %d %s %d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">weekdays</span><span class="plain-syntax">[</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_wday</span><span class="plain-syntax">],</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mday</span><span class="plain-syntax">, </span><span class="identifier-syntax">months</span><span class="plain-syntax">[</span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mon</span><span class="plain-syntax">], </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">+1900);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">infocom</span><span class="plain-syntax">, </span><span class="string-syntax">"%02d%02d%02d"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_year</span><span class="plain-syntax">-100, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mon</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_mday</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">timestamp</span><span class="plain-syntax">, </span><span class="string-syntax">"%02d:%02d.%02d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_hour</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_min</span><span class="plain-syntax">, </span><span class="identifier-syntax">the_present</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">tm_sec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"DATESTAMP"</span><span class="plain-syntax">, </span><span class="identifier-syntax">datestamp</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"INFOCOMDATESTAMP"</span><span class="plain-syntax">, </span><span class="identifier-syntax">infocom</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"TIMESTAMP"</span><span class="plain-syntax">, </span><span class="identifier-syntax">timestamp</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">datestamp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">infocom</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">timestamp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Opening and closing banners.</b>Note that Inblorb customarily prints informational messages with an initial
<span class="extract"><span class="extract-syntax">!</span></span>, so that the piped output from Inblorb could be used as an <span class="extract"><span class="extract-syntax">Include</span></span>
file in I6 code, where <span class="extract"><span class="extract-syntax">!</span></span> is the comment character; that isn't in fact how
I7 uses Inblorb, but it's traditional for blorbing programs to do this.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Main::print_banner</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Main::print_banner</span></span>:<br/><a href="1-mn.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ver</span><span class="plain-syntax"> = </span><a href="../foundation/4-sm.html#SP2" class="function-link"><span class="function-syntax">Str::new</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">ver</span><span class="plain-syntax">, </span><span class="string-syntax">"inblorb "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fix_time_mode</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">ver</span><span class="plain-syntax">, </span><span class="string-syntax">"99.99"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">ver</span><span class="plain-syntax">, </span><span class="string-syntax">"[[Version Number]]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PRINT</span><span class="plain-syntax">(</span><span class="string-syntax">"! %S [executing on %S at %S]\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ver</span><span class="plain-syntax">, </span><a href="3-plc.html#SP3" class="function-link"><span class="function-syntax">Placeholders::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"DATESTAMP"</span><span class="plain-syntax">), </span><a href="3-plc.html#SP3" class="function-link"><span class="function-syntax">Placeholders::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"TIMESTAMP"</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PRINT</span><span class="plain-syntax">(</span><span class="string-syntax">"! The blorb spell (safely protect a small object "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PRINT</span><span class="plain-syntax">(</span><span class="string-syntax">"as though in a strong box).\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>The concluding banner is much smaller &mdash; empty if all went well, a single
comment line if not. But we also generate the status report page (if that has
been requested) &mdash; a single HTML file generated from a template by expanding
placeholders in the template. All of the meat of the report is in those
placeholders, of course; the template contains only some fancy formatting.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Main::print_report</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Main::print_report</span></span>:<br/><a href="1-mn.html#SP3">&#167;3</a><br/>Blorb Errors - <a href="1-be.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">error_count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">PRINT</span><span class="plain-syntax">(</span><span class="string-syntax">"! Completed: %d error(s)\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">error_count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="1-mn.html#SP7_1" class="named-paragraph-link"><span class="named-paragraph">Set a whole pile of placeholders which will be needed to generate the status page</span><span class="named-paragraph-number">7.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">status_template</span><span class="plain-syntax">) </span><a href="3-wm.html#SP9" class="function-link"><span class="function-syntax">Websites::web_copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">status_template</span><span class="plain-syntax">, </span><span class="identifier-syntax">status_file</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Main::read_css_line</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Main::read_css_line</span></span>:<br/><a href="1-mn.html#SP7_1">&#167;7.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">str</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">str</span><span class="plain-syntax">, </span><span class="string-syntax">"%S\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7_1" class="paragraph-anchor"></a><b>&#167;7.1. </b>If it isn't apparent what these placeholders do, take a look at
the template file called <span class="extract"><span class="extract-syntax">CblorbModel.html</span></span> in the Inform application &mdash;
that's where they're used.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Set a whole pile of placeholders which will be needed to generate the status page</span><span class="named-paragraph-number">7.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">error_count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUS"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Failed"</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUSLOW"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"failed"</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUSIMAGE"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"inform:/outcome_images/cblorb_failed.png"</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUSTEXT"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><a href="../foundation/4-sm.html#SP27" class="function-link"><span class="function-syntax">Str::literal</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">U</span><span class="string-syntax">"Inform translated your source text as usual, to manufacture a 'story "</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">U</span><span class="string-syntax">"file': all of that worked fine. But the Release then went wrong, for "</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">U</span><span class="string-syntax">"the following reason:&lt;p&gt;&lt;ul&gt;[CBLORBERRORS]&lt;/ul&gt;"</span><span class="plain-syntax">), </span><span class="constant-syntax">0</span>
<span class="plain-syntax">        );</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBERRORS"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"No problems occurred"</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUS"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Succeeded"</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUSLOW"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"succeeded"</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="3-plc.html#SP5" class="function-link"><span class="function-syntax">Placeholders::set_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"CBLORBSTATUSIMAGE"</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"file:</span><span class="comment-syntax">[SMALLCOVER]", 0);</span>
<span class="string-syntax">        Placeholders::set_to(I"</span><span class="identifier-syntax">CBLORBSTATUSTEXT</span><span class="string-syntax">",</span>
<span class="string-syntax">            Str::literal(U"</span><span class="identifier-syntax">All</span><span class="plain-syntax"> </span><span class="identifier-syntax">went</span><span class="plain-syntax"> </span><span class="identifier-syntax">well</span><span class="plain-syntax">. </span><span class="identifier-syntax">I</span><span class="character-syntax">'ve put the released material into the '</span><span class="identifier-syntax">Release</span><span class="character-syntax">' subfolder "</span>
<span class="character-syntax">                U"of the Materials folder for the project: you can take a look with "</span>
<span class="character-syntax">                U"the menu option &lt;b&gt;Release &amp;gt; Open Materials Folder&lt;/b&gt; or by clicking "</span>
<span class="character-syntax">                U"the blue folders above.&lt;p&gt;"</span>
<span class="character-syntax">                U"Releases can range in size from a single blorb file to a medium-sized website. "</span>
<span class="character-syntax">                U"Here'</span><span class="identifier-syntax">s</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">we</span><span class="plain-syntax"> </span><span class="identifier-syntax">currently</span><span class="plain-syntax"> </span><span class="identifier-syntax">have:</span><span class="function-syntax">&lt;p&gt;</span><span class="string-syntax">"), 0</span>
<span class="string-syntax">        );</span>
<span class="string-syntax">        Requests::report_requested_material(I"</span><span class="identifier-syntax">CBLORBSTATUSTEXT</span><span class="string-syntax">");</span>
<span class="string-syntax">    }</span>
<span class="string-syntax">    if (blorb_file_size &gt; 0) {</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILESIZE</span><span class="string-syntax">", blorb_file_size/1024);</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILEPICTURES</span><span class="string-syntax">", no_pictures_included);</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILESOUNDS</span><span class="string-syntax">", no_sounds_included);</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILEDATAFILES</span><span class="string-syntax">", no_data_files_included);</span>
<span class="string-syntax">        PRINT("</span><span class="plain-syntax">! </span><span class="identifier-syntax">Completed:</span><span class="plain-syntax"> </span><span class="identifier-syntax">wrote</span><span class="plain-syntax"> </span><span class="identifier-syntax">blorb</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="string-syntax">");</span>
<span class="string-syntax">        PRINT("</span><span class="plain-syntax">%</span><span class="identifier-syntax">d</span><span class="plain-syntax"> </span><span class="identifier-syntax">picture</span><span class="plain-syntax">(</span><span class="identifier-syntax">s</span><span class="plain-syntax">), %</span><span class="identifier-syntax">d</span><span class="plain-syntax"> </span><span class="identifier-syntax">sound</span><span class="plain-syntax">(</span><span class="identifier-syntax">s</span><span class="plain-syntax">), %</span><span class="identifier-syntax">d</span><span class="plain-syntax"> </span><span class="identifier-syntax">data</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">(</span><span class="identifier-syntax">s</span><span class="plain-syntax">)\</span><span class="identifier-syntax">n</span><span class="string-syntax">",</span>
<span class="string-syntax">            no_pictures_included, no_sounds_included, no_data_files_included);</span>
<span class="string-syntax">    } else {</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILESIZE</span><span class="string-syntax">", 0);</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILEPICTURES</span><span class="string-syntax">", 0);</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILESOUNDS</span><span class="string-syntax">", 0);</span>
<span class="string-syntax">        Placeholders::set_to_number(I"</span><span class="identifier-syntax">BLORBFILEDATAFILES</span><span class="string-syntax">", 0);</span>
<span class="string-syntax">        PRINT("</span><span class="plain-syntax">! </span><span class="identifier-syntax">Completed:</span><span class="plain-syntax"> </span><span class="identifier-syntax">no</span><span class="plain-syntax"> </span><span class="identifier-syntax">blorb</span><span class="plain-syntax"> </span><span class="identifier-syntax">output</span><span class="plain-syntax"> </span><span class="identifier-syntax">requested</span><span class="plain-syntax">\</span><span class="identifier-syntax">n</span><span class="string-syntax">");</span>
<span class="string-syntax">    }</span>
<span class="string-syntax">    if (status_template) {</span>
<span class="string-syntax">        filename *css_filename = NULL;</span>
<span class="string-syntax">        pathname *css_path = Filenames::up(status_template);</span>
<span class="string-syntax">        TEMPORARY_TEXT(platform_variation)</span>
<span class="string-syntax">        WRITE_TO(platform_variation, "</span><span class="plain-syntax">%</span><span class="identifier-syntax">s</span><span class="plain-syntax">-</span><span class="identifier-syntax">platform</span><span class="plain-syntax">.</span><span class="identifier-syntax">css</span><span class="string-syntax">", PLATFORM_STRING);</span>
<span class="string-syntax">        css_filename = Filenames::in(css_path, platform_variation);</span>
<span class="string-syntax">        if (TextFiles::exists(css_filename) == FALSE) {</span>
<span class="string-syntax">            css_filename = Filenames::in(css_path, I"</span><span class="identifier-syntax">platform</span><span class="plain-syntax">.</span><span class="identifier-syntax">css</span><span class="string-syntax">");</span>
<span class="string-syntax">        }</span>
<span class="string-syntax">        if (TextFiles::exists(css_filename)) {</span>
<span class="string-syntax">            TEMPORARY_TEXT(css)</span>
<span class="string-syntax">            TextFiles::read(css_filename, FALSE, "</span><span class="identifier-syntax">can</span><span class="character-syntax">'t open css file",</span>
<span class="character-syntax">                TRUE, Main::read_css_line, NULL, css);</span>
<span class="character-syntax">            Placeholders::set_to(I"PLATFORMCSS", css, 0);</span>
<span class="character-syntax">        }</span>
<span class="character-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="1-mn.html#SP7">&#167;7</a>.</li></ul>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="1-bsc.html">&#10094;</a></li><li class="progresschapter"><a href="M-ui.html">M</a></li><li class="progresscurrentchapter">1</li><li class="progresssection"><a href="1-bsc.html">bsc</a></li><li class="progresscurrent">mn</li><li class="progresssection"><a href="1-be.html">be</a></li><li class="progresssection"><a href="1-bp.html">bp</a></li><li class="progresschapter"><a href="2-bw.html">2</a></li><li class="progresschapter"><a href="3-rls.html">3</a></li><li class="progressnext"><a href="1-be.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

